package cn.cstech.aijia.ui.base.fragments;

import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.TextView;

import com.lidroid.xutils.db.annotation.Check;

import java.util.ArrayList;
import java.util.List;

import cn.cstech.aijia.R;
import cn.cstech.aijia.ui.base.BaseFragment;
import cn.cstech.aijia.ui.project.ProjectListActivity;

/**
 * Created with Android Studio.
 * Title:MainFragment
 * Description:
 * Copyright:Copyright (c) 2014
 * Company:中国平安健康保险有限公司
 * Author:Alice
 * Date:15/9/1
 * Time:下午5:17
 * Version 1.0
 */
public class MainFragment extends BaseFragment{
    private EditText et_jzmj;
    private Spinner sp_hx;
    private Spinner sp_fx;
    private Spinner sp_zxdc;
    private Spinner sp_zxfg;
    private EditText et_ysje;
    private CheckBox cb_auto_push;
    private Button btn_submit;

    @Override
    public View onCreateViewCustom(LayoutInflater inflater, ViewGroup container) {
        View view = inflater.inflate(R.layout.fg_main, null);

        initViews(view);
        initDatas();
        return view;
    }

    private void initViews(View v){
        et_jzmj = (EditText)v.findViewById(R.id.et_jzmj);
        sp_hx = (Spinner)v.findViewById(R.id.sp_hx);
        sp_fx = (Spinner)v.findViewById(R.id.sp_fx);
        sp_zxdc = (Spinner)v.findViewById(R.id.sp_zxdc);
        sp_zxfg = (Spinner)v.findViewById(R.id.sp_zxfg);
        et_ysje = (EditText)v.findViewById(R.id.et_ysje);
        cb_auto_push = (CheckBox)v.findViewById(R.id.cb_auto_push);
        btn_submit = (Button)v.findViewById(R.id.btn_submit);

        btn_submit.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(getActivity(), ProjectListActivity.class));
            }
        });
    }

    private void initDatas(){
        String[] hxDatas = getResources().getStringArray(R.array.array_hx);
        ArrayAdapter<String> hxAdapter= new ArrayAdapter<String>(getActivity(),
                android.R.layout.simple_spinner_item,
                hxDatas);
        hxAdapter.setDropDownViewResource(android.R.layout.simple_spinner_item);
        sp_hx.setAdapter(hxAdapter);

        String[] fxDatas = getResources().getStringArray(R.array.array_fx);
        ArrayAdapter<String> fxAdapter= new ArrayAdapter<String>(getActivity(),
                android.R.layout.simple_spinner_item,
                fxDatas);
        hxAdapter.setDropDownViewResource(android.R.layout.simple_spinner_item);
        sp_fx.setAdapter(fxAdapter);

        String[] dcDatas = getResources().getStringArray(R.array.array_dc);
        ArrayAdapter<String> dcAdapter= new ArrayAdapter<String>(getActivity(),
                android.R.layout.simple_spinner_item,
                dcDatas);
        dcAdapter.setDropDownViewResource(android.R.layout.simple_spinner_item);
        sp_zxdc.setAdapter(dcAdapter);

        String[] fgDatas = getResources().getStringArray(R.array.array_fg);
        ArrayAdapter<String> fgAdapter= new ArrayAdapter<String>(getActivity(),
                android.R.layout.simple_spinner_item,
                fgDatas);
        fgAdapter.setDropDownViewResource(android.R.layout.simple_expandable_list_item_1);
        sp_zxfg.setAdapter(fgAdapter);
    }

    @Override
    public void onTitleBarCreate(){
        setTitleText("首页");
    }
}
